<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>我的学院</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7System.out.println(); -->
    <!--link导入外部的css，js样式，如果导入的资源和本页面在同一个文件夹下，直接文件名即可-->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- jQuery 3 -->
    <script th:src="@{/asserts/bower_components/jquery/dist/jquery.min.js}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script th:src="@{/asserts/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/AdminLTE.min.css}">
    <!--联想查询-->
    <script th:src="@{/asserts/Apolar_sh/lib/js/bigautocomplete.js}"></script>
    <link rel="stylesheet" th:href="@{/asserts/Apolar_sh/lib/css/bigautocomplete.css}" type="text/css"/>
    <script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>
    <script th:src="@{/asserts/Apolar_sh/lib/js/fileinput.min.js}"></script>
    <script th:src="@{/asserts/Apolar_sh/lib/js/fileinput_locale_zh.js}"></script>
    <link th:href="@{/asserts/Apolar_sh/lib/css/fileinput.min.css}" media="all" rel="stylesheet" type="text/css"/>

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style type="text/css">
        .search {
            margin-top: 40px;
            margin-left: 40px;
            position: relative;
        }

        #MyTable td {
            text-align: center;
        }

        th {
            text-align: center;
        }

        nav {
            margin-top: -20px;
        }
        #home {
            display: block;
            position: absolute;
            right: 10px;
            top: 8px;
            z-index: 9999;
            font-size: 30px;
        }

        #refresh {
            display: block;
            position: absolute;
            right: 46px;
            top: 10px;
            z-index: 9999;
            font-size: 26px;
        }
    </style>

</head>
<body>
<span>
    <a id="refresh" class="fa fa-refresh"  href="javascript:location.reload()"></a>
    <a id="home" class="fa fa-home" th:href="@{/campus/infoFindAll}"></a>
</span>


<div class="wrapper">
    <!-- Content Wrapper. Contains page content -->

    <!-- Main content -->
    <section class="content-header">
        <h4>
            <i class="fa fa-search"></i> 搜索我的院校
        </h4>
    </section>
    <div class="search" style="margin-top: 15px;">

        <div class="row">
            <div class="col-xs-7">
                <form class="form-inline" th:action="@{/campus/search}">
                    <div class="form-group">
                        <label for="campusName">院校名称：</label>
                        <input type="text" class="form-control" id="campusName" name="campusName"
                               th:value="${campusName}"
                               placeholder="请输入院校名称">
                    </div>
                    <div class="form-group">
                        <label for="personname"> 渠道专员：</label>
                        <input type="text" class="form-control" id="personname" name="personname"
                               th:if="${session.user.authority == 1}"
                               th:value="${personname}"
                               placeholder="请输入渠道专员">
                        <input type="text" class="form-control" id="personname" name="personname"
                               th:if="${session.user.authority != 1}"
                               th:value="${session.user.personname}" readonly>
                        <!--<select class="form-control" name="marketEmployeeId">-->
                        <!--<option selected="" value="-1">&#45;&#45;请选择&#45;&#45;</option>-->
                        <!--<option th:value="${user.uid}" th:each="user:${users}" th:text="${user.personname}"></option>-->
                        <!--</select>-->
                    </div>
                    <button type="submit" class="btn btn-success"><i class="fa fa-search"></i> 搜索</button>
                </form>
            </div>
            <div class="col-xs-2">
                <a class="btn btn-info" th:href="@{/campus/saveUI}">
                    <i class="fa fa-plus"></i> 添加校园信息
                </a>
            </div>
            <div class="col-xs-1" th:if="${session.user.authority == 1}">
                <a class="btn btn-info" th:href="@{/market}">
                    查看报表
                </a>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </div>

    <!-- /.content -->
</div>

<div class="wrapper">


    <!-- Content Header (Page header) -->
    <section class="content-header" style="margin-top: -15px;">
        <h4>
            <!--<i class="fa fa-navicon"></i> 我的院校-->

            <div class="form-group" style="padding-bottom: 0px;margin-bottom: 0px">
                <i th:if="${searchUrl==null}" class="fa fa-navicon col-sm-2 control-label" style="margin-top: 4px">我的院校列表</i>
                <i th:if="${searchUrl!=null}" class="fa fa-navicon col-sm-2 control-label" style="margin-top: 4px">搜索结果列表</i>
                <div th:if="${info==null||pageBean!=null}">
                    <span style="margin-bottom: 0px">每页显示：</span>
                    <span class="control-label">
                    <select class="" name="pageSize" id="pageSize"
                            th:onchange="changePage([[${searchUrl}]])">
                        <option th:selected="${pageBean.pageSize==5}" value="5">&nbsp;5</option>
                        <option th:selected="${pageBean.pageSize==10}" value="10">10</option>
                        <option th:selected="${pageBean.pageSize==20}" value="20">20</option>
                    </select>
                </span>
                </div>

            </div>
        </h4>

    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div th:if="${info != null}" style="width: 270px;margin: auto">
                        <p style="color: #ff0000;font-size: 30px;font-weight: bold">[[${info}]]</p>
                    </div>
                    <!-- /.box-header 部门列表的显示  table  表格  th/td单元个   th字体加粗，行标题-->
                    <div class="box-body" th:if="${info == null}">
                        <form method="post" th:action="@{/campus/deleteAll}">
                            <table id="MyTable" class="table table-bordered table-hover">
                                <tbody>
                                <tr>
                                    <th th:if="${session.user.authority != 3}">选择</th>
                                    <th>院校名称</th>
                                    <th>院系专业</th>
                                    <th>渠道专员</th>
                                    <th>联系人</th>
                                    <th>院校详情</th>
                                    <th>核心事件</th>
                                    <th>创建时间</th>
                                    <th>修改时间</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                                <tr th:each="campus:${pageBean.list}">
                                    <td th:if="${session.user.authority != 3}">
                                        <input type="checkbox" id="check" name="campusIds" class="checks"
                                               th:value="${campus.campusId}"/>
                                    </td>
                                    <td th:text="${campus.campusName}">清华大学</td>
                                    <td th:text="${campus.campusMajor}">计算机科学与技术</td>
                                    <td th:text="${campus.personname}">张老师</td>
                                    <td>
                                        <a class="btn btn-info"
                                           th:href="@{/CampusConn/findAll(campusId=${campus.campusId},RcurrentPage=${pageBean.pageNum},RpageSize=${pageBean.pageSize})}">
                                            联系人
                                        </a>
                                    </td>
                                    <td>
                                        <a class="btn btn-info"
                                           th:href="@{/campus/campusInfo(campusId=${campus.campusId},RcurrentPage=${pageBean.pageNum},RpageSize=${pageBean.pageSize})}">
                                            院校信息
                                        </a>
                                    </td>
                                    <td>
                                        <a class="btn btn-info"
                                           th:href="@{/coreEvent/findGroup(campusId=${campus.campusId},RcurrentPage=${pageBean.pageNum},RpageSize=${pageBean.pageSize})}">
                                            核心事件
                                        </a>
                                    </td>
                                    <td th:text="${#dates.format(campus.campusCreateDate, 'yyyy-MM-dd')}">2019-06-28
                                    </td>
                                    <td th:text="${#dates.format(campus.campusModifyDate, 'yyyy-MM-dd')}">2019-07-22
                                    </td>
                                    <!--<td th:text="${campus.campusRemarks}">无</td>-->
                                    <td>
                                        <a class="btn btn-info " data-toggle="modal"
                                           th:data-target="${'#detilModal'+campus.campusId}">
                                            <i class="fa fa-info"></i> 备注
                                        </a>
                                        <!-- 查看详情 Modal -->
                                        <div class="modal fade" th:id="${'detilModal'+campus.campusId}"
                                             tabindex="-1" role="dialog"
                                             aria-labelledby="myModalLabel">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h4 class="modal-title" id="myModalLabel"
                                                            style="text-align: center;"><i class="fa fa-info"></i>&nbsp;&nbsp;备注
                                                        </h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <table class="table table-striped table-bordered">
                                                            <tbody>
                                                            <tr>
                                                                <td style="width: 30%;"><strong>备注:</strong></td>
                                                                <td style="word-break:break-all;"
                                                                    th:text="${campus.campusRemarks}">备注
                                                                </td>
                                                            </tr>
                                                            </tbody>
                                                        </table>
                                                        <div>
                                                            <button type="button" class="btn btn-info btn-sm"
                                                                    data-dismiss="modal" style="margin: 0 0 0 85%;">关 闭
                                                            </button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- 查看详情 Modal -->
                                    </td>


                                    <td>
                                        <a class="btn btn-warning"
                                           th:href="@{/campus/updateById(campusId=${campus.campusId},currentPage=${pageBean.pageNum},pageSize=${pageBean.pageSize})}">
                                            <i class="fa fa-edit"></i> 修改
                                        </a>
                                        <a id="delete" class="btn btn-danger" th:if="${session.user.authority != 3}"
                                           th:onclick="deleteById([[${campus.campusId}]])">
                                            <i class="fa fa-trash"></i> 删除
                                        </a>
                                    </td>
                                </tr>

                                <tr>
                                    <td th:if="${session.user.authority != 3}">
                                        <label><input type="checkbox" name="" id="all" value=""/>全选</label>
                                    </td>
                                    <td colspan="13" style="text-align:left;padding-left:20px;">
                                        <button th:if="${session.user.authority != 3}" class="btn btn-danger"
                                                onclick="return confirm('确认要删除？')" type="submit">
                                            <i class="fa fa-trash"></i> 删除
                                        </button>
                                        <a class="btn btn-primary" th:href="@{/campus/exportTemplate}">
                                            <i class="fa fa-download"></i> 导出当前页EXCEL模板
                                        </a>

                                        <a class="btn btn-primary" th:href="@{/campus/export}"
                                           th:if="${session.user.authority == 1}">
                                            <i class="fa fa-download"></i> 导出到EXCEL
                                        </a>

                                        <a class="btn btn-primary" data-toggle="modal" data-target="#mydialog1">
                                            <i class="fa fa-upload"></i> 导入EXCEL
                                        </a>
                                    </td>
                                </tr>
                                <tr>

                                </tr>
                                </tbody>
                            </table>
                        </form>
                        <!-- Excel Modal -->
                        <div class="modal fade" id="mydialog1"
                             tabindex="-1" role="dialog" data-backdrop='static'
                             aria-labelledby="myModalLabel">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h4 class="modal-title" style="text-align: center;">
                                            <i class="fa fa-upload"></i>&nbsp;&nbsp;导入EXCEL
                                        </h4>
                                    </div>
                                    <div class="modal-body">
                                        <form id="uploadForm" enctype="multipart/form-data">
                                            <div class="form-group">
                                                <input id="input-b2" name="file" size="100" type="file" class="file"
                                                       data-show-preview="true"
                                                       data-show-upload="false"
                                                       data-show-cancel="false"
                                                       accept="application/vnd.ms-excel"
                                                       placeholder="请选择一个Excel文件">
                                            </div>
                                            <div class="modal-footer" style="padding-right: 0;padding-bottom:0;">
                                                <button type="button" class="btn btn-default btn-sm"
                                                        data-dismiss="modal">
                                                    <i class="fa fa-close"></i> &nbsp;&nbsp;取&nbsp;&nbsp;消&nbsp;&nbsp;
                                                </button>
                                                <button type="button" class="btn btn-success btn-sm"
                                                        th:onclick="uploadExcel()">
                                                    <i class="fa fa-upload"></i> &nbsp;&nbsp;上&nbsp;&nbsp;传&nbsp;&nbsp;
                                                </button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- Excel Modal -->
                        <input id="currentPage" th:value="${pageBean.pageNum}" hidden>
                        <input id="currentPageSize" th:value="${pageBean.size}" hidden>
                        <input id="lastPage" th:value="${pageBean.pages}" hidden>
                        <input id="pageSize" th:value="${pageBean.pageSize}" hidden>
                        <!-- 分页 -->
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                <li>
                                    <a th:if="${pageBean.pageNum != 1 && searchUrl == null}"
                                       th:href="@{/campus/infoFindAll(currentPage=1,pageSize=${pageBean.pageSize})}">首页</a>
                                    <a th:if="${pageBean.pageNum != 1 && searchUrl != null}"
                                       th:href="@{${searchUrl}(campusName=${campusName},personname=${personname},currentPage=1,pageSize=${pageBean.pageSize})}">首页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==1 }"
                                       href="javascript:void(0)">首页</a>
                                </li>

                                <li th:if="${pageBean.pageNum!=1 && searchUrl == null }">
                                    <a th:href="@{/campus/infoFindAll(currentPage=${pageBean.pageNum-1},pageSize=${pageBean.pageSize})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=1 && searchUrl != null }">
                                    <a th:href="@{${searchUrl}(campusName=${campusName},personname=${personname},currentPage=${pageBean.pageNum-1},pageSize=${pageBean.pageSize})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li class="disabled" th:if="${pageBean.pageNum==1 }">
                                    <a href="javascript:void(0)" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>

                                <li th:classappend="${pageBean.pageNum==pageIndex}?'active':''"
                                    th:each="pageIndex:${pageValue}">
                                    <a
                                            th:if="${pageBean.pageNum==pageIndex}"
                                            th:text="${pageIndex}"></a>
                                    <a th:if="${pageIndex==-1}" style="cursor: default;opacity: 0.6;">
                                        ...
                                    </a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1 && searchUrl == null }"
                                       th:href="@{/campus/infoFindAll(currentPage=${pageIndex},pageSize=${pageBean.pageSize})}"
                                       th:text="${pageIndex}"></a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1 && searchUrl != null }"
                                       th:href="@{${searchUrl}(campusName=${campusName},personname=${personname},currentPage=${pageIndex},pageSize=${pageBean.pageSize})}"
                                       th:text="${pageIndex}"></a>
                                </li>

                                <li class="disabled" th:if="${pageBean.pageNum==pageBean.pages }">
                                    <a href="javascript:void(0)" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=pageBean.pages && searchUrl == null }">
                                    <a th:href="@{/campus/infoFindAll(currentPage=${pageBean.pageNum+1},pageSize=${pageBean.pageSize})}"
                                       aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=pageBean.pages && searchUrl != null}">
                                    <a th:href="@{${searchUrl}(campusName=${campusName},personname=${personname},currentPage=${pageBean.pageNum+1},pageSize=${pageBean.pageSize})}"
                                       aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>

                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages && searchUrl == null}"
                                       th:href="@{/campus/infoFindAll(currentPage=${pageBean.pages},pageSize=${pageBean.pageSize})}">末页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages && searchUrl != null }"
                                       th:href="@{${searchUrl}(campusName=${campusName},personname=${personname},currentPage=${pageBean.pages},pageSize=${pageBean.pageSize})}">末页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==pageBean.pages }"
                                       href="javascript:void(0)">末页</a>
                                </li>
                            </ul>
                        </nav>

                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>

<!-- ./wrapper -->

<!-- DataTables -->
<script th:src="@{/asserts/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/asserts/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/asserts/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/asserts/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/asserts/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/asserts/dist/js/demo.js}"></script>
<!-- page script -->
<!--联系查询-->
<script th:src="@{/asserts/Apolar_sh/lib/js/bigautocomplete.js}"></script>

<script>
    $("#all").click(function () {
        if (this.checked) {
            $(".checks").prop("checked", true);
            $("#all").prop("value", "全不选");
        } else {
            $(".checks").prop("checked", false);
            $("#all").prop("value", "全选");
        }
    });

    function changePage(searchUrl) {
        if (searchUrl != null && searchUrl.trim() != "") {
            // alert('[[${#httpServletRequest.getContextPath()}]]' + searchUrl + '?campusName=' + $("#campusName").val() + '&personname'+ $("#personname").val()+ '&pageSize=' + $("#pageSize").val());
            window.location.href = '[[${#httpServletRequest.getContextPath()}]]' + searchUrl + '?campusName=' + $("#campusName").val() + '&personname' + $("#personname").val() + '&pageSize=' + $("#pageSize").val();
        } else {
            window.location.href = '[[${#httpServletRequest.getContextPath()}]]/campus/infoFindAll?pageSize=' + $("#pageSize").val();
        }
    }

    /*联想输入*/
    $(function () {
        $("#personname").bigAutocomplete({
            url: '[[${#httpServletRequest.getContextPath()}]]/find/marketJson',
        });
    })

    function deleteById(campusId) {
        layer.confirm("确认删除？",
            {
                btn: ['确定', '取消'] //按钮
            },
            function () {
                var currentPageSize = $("#currentPageSize").val();
                var currentPage = $("#currentPage").val();
                var lastPage = $("#lastPage").val();
                var pageSize = $("#pageSize").val();
                $.ajax({
                    url: '[[${#httpServletRequest.getContextPath()}]]/campus/deleteById?currentPageSize=' + currentPageSize + '&currentPage=' + currentPage + '&lastPage=' + lastPage,
                    data: {
                        'campusId': campusId
                    },
                    success: function (result) {
                        console.log(result);
                        if (result == '1') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.reload();
                        } else if (result == '0') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.replace("[[${#httpServletRequest.getContextPath()}]]/campus/infoFindAll?currentPage=" + (currentPage - 1) + "&pageSize=" + pageSize);
                        }
                        else {
                            layer.msg('删除失败！', {icon: 0, time: 1000});
                        }

                    }
                })
            },
            function () {
                layer.msg('已取消！', {icon: 0, time: 500});
                return false;
            }
        );
    };
    /*文件上传*/
    var $uploadExcel = $("#input-b2");

    function uploadExcel() {
        if ($uploadExcel.val() === "") {
            layer.msg('亲，请选择文件哦!', {
                icon: 0,
                time: 1500
            });
        } else {
            var file = document.getElementById("input-b2").files[0];
            var formData = new FormData();
            formData.append("file", file);
            layer.msg("正在导入,请稍等...", {
                icon: 1,
                time: 1000
            });
            $.ajax({
                type: 'POST',
                url: './import',
                data: formData,
                dataType: 'json',
                processData: false,
                contentType: false,
                mimeType: "multipart/form-data",
                success: function (data) {
                    if (data == '1') {
                        layer.msg('上传成功', {icon: 1,time: 500});
                        $('#mydialog1').modal('hide');
                        setTimeout(function () {
                            location.reload();
                        }, 500);
                    } else {
                        layer.msg('上传失败', {icon: 0, time: 2000 });
                        $('#mydialog1').modal('hide');
                    }
                },
                error: function (data) {
                    console.log(data.msg);
                }
            })
        }
    }
</script>
</body>
</html>